#include <iostream>

class Test
{
public:
    /* 初始化列表 */
    Test(int a,int b):m_a(a)
    {
        std::cout<<"构造函数"<<std::endl;
        m_b = b;
    }
    void show()
    {
        std::cout<<"m_a:"<<m_a<<std::endl;
        std::cout<<"m_b:"<<m_b<<std::endl;
    }

#if 0
    Test(const Test& t)
    {
        std::cout<<"拷贝构造函数"<<std::endl;
        // p = new int(*t.p);
        p = new int;
        *p = *t.p;
    }

    Test& operator=(const Test& t)
    {
        std::cout << "赋值运算符重载" << std::endl;
        if (this != &t) {
            delete p;  // 释放原来的内存
            p = new int;  // 分配新的内存
            *p = *(t.p);  // 进行深拷贝
        }
        return *this;
    }
#endif

    ~Test()
    {
        std::cout<<"析构函数"<<std::endl;
    }

private:
    const int m_a;//常成员变量
    int m_b;
};

int main()
{
    Test s(1,4);
    s.show();


    return 0;
}